$(function(){
	var nowtime = new Date();
    var year = nowtime.getFullYear();
    var htmlStr = "";
    $("#incomeMess").html("本店"+year+"年每月收入统计图");
    for(var i=0;i<5;i++){
    	htmlStr+="<option value="+(year-i)+">"+(year-i)+"年收入</option>";
    }
	$("#select").html(htmlStr);
	$('#select').on('change', function() {
        var val = $(this).val();
        showIncome(val);
        $("#incomeMess").html("本店"+val+"年每月收入统计图");
    });

    showIncome(year);
	
});
function showIncome(yearIncome){

	var url = "../../userAction/selectIncome.action";
	var data = {"year":yearIncome};
	$.post(url,data,function(msg){
		var myChart = echarts.init(document.getElementById('main'));
		var option = {
		    color: ['#3398DB'],
		    tooltip : {
		        trigger: 'axis',
		        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
		            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
		        }
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis : [
		        {
		            type : 'category',
		            data : ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二 月'],
		            axisTick: {
		                alignWithLabel: true
		            }
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value'
		        }
		    ],
		    series : [
		        {
		            name:'收入',
		            type:'bar',
		            barWidth: '60%',
		            data:msg
		        }
		    ]
		};
		myChart.setOption(option);
	},"json");
}
